//
//  AccountDropCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/6.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "AccountDropCell.h"

#define AccountDropCellID @"AccountDropCellID"

@implementation AccountDropCell

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    AccountDropCell *cell = [tableView dequeueReusableCellWithIdentifier:AccountDropCellID];
    if(!cell)
    {
        cell = [[AccountDropCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:AccountDropCellID];
    }
    return cell;
}


#pragma mark - init method
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 关闭cell点击效果
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        // 初始化UI
        [self initView];
        // 布局
        [self initLayout];
    }
    return self;
}


- (void)initView {
    
    [self.contentView addSubview:self.account];
    [self.contentView addSubview:self.deleteBtn];
}



- (void) initLayout {
    
    _account.size = CGSizeMake(200, self.height);
    _account.mj_x = 105;
    _account.mj_y = 0;
    
    _deleteBtn.size = CGSizeMake(16, 16);
    _deleteBtn.mj_x = KScreenWidth - _deleteBtn.width - 40;
    _deleteBtn.mj_y = (self.height - _deleteBtn.height)/2.0;
}


#pragma mark - getter and setter

- (UILabel *)account {
    if (!_account) {
        _account = [[UILabel alloc] init];
        _account.textColor = UIColorFromRGB(0x363636);
        _account.font = mFont(14);
    }
    return _account;
}


- (UIButton *)deleteBtn {
    if (!_deleteBtn) {
        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteBtn.adjustsImageWhenHighlighted = NO;
        [_deleteBtn setBackgroundImage:[UIImage imageNamed:@"login_accountdrop_ delete"] forState:UIControlStateNormal];
        
        @weakify(self);
        _deleteBtn.tapBlock = ^{
            @strongify(self);
            if (self.dealDeletePhotoBlock) {
                self.dealDeletePhotoBlock();
            }
        };
    }
    return _deleteBtn;
}


@end
